package handler;

import dto.ActionDTO;
import dto.RespDTO;
import dto.RespStatusTypeEnum;
import service.Store;
import utils.LoggerUtil;

import java.io.IOException;
import java.io.ObjectOutputStream;

public class SetActionHandler implements ActionHandler{
    @Override
    public void handle(Store store, ActionDTO dto, ObjectOutputStream oos) throws IOException {
        store.set(dto.getTable(), dto.getKey(), dto.getValue());
        RespDTO resp = new RespDTO(RespStatusTypeEnum.SUCCESS, null);
        LoggerUtil.debug(LOGGER, "[SocketServerHandler][run]: {}", "set action resp" + dto.toString());
        oos.writeObject(resp);
        oos.flush();
    }
}
